
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sj" tagdir="/WEB-INF/tags/spring-jquery-tags"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<link rel="stylesheet" type="text/css" href="<c:url value='/css/jquery/flexigrid.pack.css' />" />
<script type="text/javascript" src="<c:url value='/js/jquery/flexigrid.pack.js' />"></script>
<script type="text/javascript" src="<c:url value='/js/util.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/payment-line-item.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/jquery/jquery.numeric.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/jquery/jquery.formatCurrency-1.4.0.pack.js'/>"></script>
<script type="text/javascript">
	$(document).ready(
			function() {
				$('#pageTitle').text('<spring:message code="editPaymentrequest.heading.paymentReqProcessing" />');
				
				var cancelRequestedMessage = '<spring:message code="status.payment.process.cancelrequested" />';
				var statusCode = '${paymentrequest.statusCode}';
				if(cancelRequestedMessage == statusCode) {
					$('#nextActionButton').click(function() {
						var dialogBody = '';
						dialogBody += 'A request to cancel this payment request has ';
						dialogBody += 'been submitted by the originator. Do you want to cancel ';
						dialogBody += 'the payment request, or continue processing the ';
						dialogBody += 'payment?';
						$('<div>' + dialogBody + '</div>').dialog({
							modal: true,
							height: 300,
							width: 400,
							buttons: 
						          {
									'Cancel' : function() {
										var nextactionValue = '<spring:message code="editPaymentrequest.label.prCancel" />';
										var nextactionname = '<spring:message code="name.button.nextaction" />';
										$(this).dialog('close');
										$('#editPaymentrequestForm').append('<input type="hidden" name="' + nextactionname + '" value="' + nextactionValue + '" />');
										$('#editPaymentrequestForm').submit();
									},
									'Continue Processing' : function() {
										var nextactionValue = '<spring:message code="name.button.continuepaymentrequest" />';
										var nextactionname = '<spring:message code="name.button.nextaction" />';
										$(this).dialog('close');
										$('#editPaymentrequestForm').append('<input type="hidden" name="' + nextactionname + '" value="' + nextactionValue + '" />');
										$('#editPaymentrequestForm').submit();
									}
						          },
						  	close: function(event, ui) {
						  		$(this).dialog('destroy');		  		
						  	}
						});
						return false;
					});
				}
				
				var arr_projects = new Array();
				<c:forEach items="${cipeProjects}" var="project" varStatus="status">
					var project${status.index} = new Object();
					project${status.index}.id = '${project.id}';
					project${status.index}.projectId = '${project.projectId}';
					project${status.index}.projectType = '${project.projectType}';
					project${status.index}.title = '${project.escapedTitle}';
					project${status.index}.status = '${project.status}';
					project${status.index}.region = '${project.escapedRegion}';
					project${status.index}.country = '${project.escapedCountry}';
					project${status.index}.acronym = '${project.escapedAcronym}';
					project${status.index}.formattedStartDate = '${project.formattedStartDate}';
					project${status.index}.formattedEndDate = '${project.formattedEndDate}';
					project${status.index}.partnerName = '${project.escapedPartnerName}';
					project${status.index}.override = '${project.override}';
					project${status.index}.remainingFunds = ${project.remainingFunds};
					project${status.index}.partnerGrant = '${project.partnerGrant}';
					project${status.index}.displayName = '${project.displayName}';
					arr_projects[${status.index}] = project${status.index};
				</c:forEach>
				var arr_account_codes = new Array();
				<c:forEach items="${accountCodes}" var="accountCode" varStatus="status">
					var accountCode${status.index} = new Object();
					accountCode${status.index}.id = '${accountCode.id}';
					accountCode${status.index}.code = '${accountCode.code}';
					accountCode${status.index}.description = '<c:out value="${accountCode.escapedDescription}" />';
					accountCode${status.index}.displayName = '<c:out value="${accountCode.displayName}" />';
					arr_account_codes[${status.index}] = accountCode${status.index};
				</c:forEach>
				var arr_lineItems = new Array();
				<c:forEach items="${paymentrequest.lineItemBeans}" var="item" varStatus="status">
					var item${status.index} = new Object();
					item${status.index}.id = '${item.id}';
					item${status.index}.accountCodeId = '${item.accountCodeId}';
					item${status.index}.cipeProjectId = '${item.cipeProjectId}';
					item${status.index}.lineItemNumber = '${item.lineItemNumber}';
					item${status.index}.prevAmount = ${item.prevAmount};
					item${status.index}.amount = ${item.amount};
					arr_lineItems[${status.index}] = item${status.index};
				</c:forEach>
				
				var paymentLineItem = new com.cipe.cmrs.model.PaymentLineItem('paymentLineItems', arr_projects, arr_account_codes, arr_lineItems, function(totalAmount) {
					$('#amount').val(totalAmount);
					$('#amount').formatCurrency('#amountLabel',{colorize: true, negativeFormat: '(-%s%n)'});
				});
				$('#amount').formatCurrency('#amountLabel',{colorize: true, negativeFormat: '(-%s%n)'});
				
				$.validator.addMethod("drop_down_required", function(value, element) {
					return (value != "");
				}, "Please select an option.");
				
				$("#editPaymentrequestForm").validate({
					rules : {
						paymentTypeId : {
							drop_down_required : true
						},
						paymentMethod : {
							drop_down_required : true
						},
						payeeId : {
							drop_down_required : true
						},
						purposeOfExpenditure : {
							required : true
						}
					}
				});

				$('.edit-payee-link').click(function() {
					loadDiv('content', 'showEditPayeePersonalInfo.do?id=' + $(this).attr('payeeId'));
				});
				
				$('#btnSignatureSelection').click(function() {
					window.open("<c:url value='/report.do' />", "_blank", "left=20, top=20, width=700, height=700, toolbar=1, resizable=0").focus();
				});
				
				$('#btnOutstandingWireTransfers').click(function() {
					window.open("<c:url value='/report.do' />", "_blank", "left=20, top=20, width=700, height=700, toolbar=1, resizable=0").focus();
				});
				
				$('#btnOver30days').click(function() {
					window.open("<c:url value='/report.do' />", "_blank", "left=20, top=20, width=700, height=700, toolbar=1, resizable=0").focus();
				});
				
				$('#btnSignatureAllUnpaid').click(function() {
					window.open("<c:url value='/report.do' />", "_blank", "left=20, top=20, width=700, height=700, toolbar=1, resizable=0").focus();
				});
				
				$('#printWireForm').click(function() {
					window.open("<c:url value='/report.do' />", "_blank", "left=20, top=20, width=700, height=700, toolbar=1, resizable=0").focus();
				});
				/*
					PRV5
					Print Payment Request' button - There should be a "dynamic button" which changes based on the 'Type' of payment request chosen.
					1) If the Payment Request Type = "Advance" or "Consultants/Contracts" or "Staff Reimbursements" or "Vendor Invoices" the button should read 'Print Payment Request Form', and should print the standard Payment Request form.
					2) If the Payment Request Type = "Partner Payment" the button should read 'Print Partner Payment Request Form', and should print the standard Partner Payment Request Form.
					3) If the Payment Request Type = "Reclass/Liquidation" the button should read 'Print Reclass Form', and should print the standard ReclassForm.		
				*/
				$("#paymentTypeId").change(function()
				{
					if(this.value==1 || this.value==2 || this.value==4 || this.value==6) {
						$('#printPaymentRequest').text('Print Payment Request Form');
						$('#printPaymentRequest').css('display','inline');
					}
					else if(this.value== 3) {
						$('#printPaymentRequest').text('Print Partner Payment Request Form');
						$('#printPaymentRequest').css('display','inline');
					} else if(this.value == 5){
						$('#printPaymentRequest').text('Print Reclass Form');
						$('#printPaymentRequest').css('display','inline');
					} else {
						$('#printPaymentRequest').css('display','none');
					}
				});
					
				$("#paymentTypeId").change();
				
				$('#printPaymentRequest').click(function() {
					window.open("<c:url value='/report.do' />?reportType=" + $('#printPaymentRequest').text(), "_blank", "left=20, top=20, width=700, height=700, toolbar=1, resizable=0").focus();
				});
				
				toggleViewEditMode(true);
				
				<c:choose>
				<c:when test="${empty canEdit || !canEdit}">
					toggleButtons(true,$('#editButton'));
				</c:when>
				<c:otherwise>				
					toggleViewEditMode(true);
					
					$('#editButton').click(function() {
						toggleViewEditMode(false);
					});
					
					$('#cancelEditButton').click(function() {
						var ans = confirm('Are you sure you want to cancel editing this record without saving it?');
						if (ans) {
							loadDiv('content', 'processPaymentrequest.do?id=${paymentrequest.id}');
						}
					});
					
				</c:otherwise>
			</c:choose>
			
			$('#payeeId').change(function() {
				if (this.value != '') {
					$('#add-paymentrequest-link').val('Edit');
					$('#payeeDesc').val($(':selected', this).text());
					loadDataViaAjax("getPayee.do", {
						"payeeId" : this.value
					}, function(bean) {
						$('#payeeAddress').val(bean.completeAddress);
					});
				} else {
					$('#add-paymentrequest-link').val('Add');
					$('#payeeDesc').val('');
					$('#payeeAddress').val('');
				}
			});
			$('#payeeId').change();
			
            $('#reason-dialog').dialog({
            	title: 'Please Enter Reason',
                autoOpen: false,
                width: 400,
                modal: true,
                resizable: false,
                buttons: {
                	"OK": function() {
                		$(this).dialog("close");
                		var reason = $('#dummyReasonRejected').val();
                		if(reason == null || reason.trim() == "") {
                			alert("Payment Request was not rejected. You must enter a reject reason to reject the payment request.");
                		} else {
	                		$('#reasonrejected').val(reason);
	               			$('#rejectPaymentStatusButton').click();
                		}
                    },
                    "Cancel": function() {
                        $(this).dialog("close");
                    }
                }
            });
            
			$('#dummyRejectStatusButton').click(function() {
				$('#reason-dialog').dialog('open');
			});
			
			$('.cancel-button').click(function() {
				loadDiv('content', 'refreshDashboard.do');
			});

			$("#receivedFromAccountingDate").datepicker();
			$("#invoiceRequestDate").datepicker();
			$("#dateToFinanace").datepicker();

			$('.list-paymentrequest-link').click(function() {
				loadDiv('content', 'showPayeeList.do');
			});
			$('#instructions-link').click(function() {
				loadDiv('content', 'showInstructionsPaymentReq.do');
			});

			$('.close-button').click(function() {
				if(confirm('Are you sure you want to close the form?')) {
					window.location = '../secure/showDashboard.do';
				}
		     });			
		});
		
    	function toggleInputOrSelectElement(viewMode,elements) {
    		for(var i = 0; i < elements.length; i++) {
    			elements[i].disabled = viewMode;
    			elements[i].readonly = viewMode;
    			var className = '';
    			if(viewMode) {
    				className = 'text_grey';
    				if(elements[i].className.indexOf("input-full-width-req") != -1) {
    					className = 'input-full-width-req ' + className;	
    				}
    			} else {
    				if(elements[i].className.indexOf("input-full-width-req") != -1) {
    					className += 'input-full-width-req text_blue';	
    				} else {
    					className += 'text_white';
    				}
    			}
    			elements[i].className = className;
    		}
    	}
    	
    	function toggleButtons(viewMode, button) {
    		if(viewMode) {
    			button.attr('disabled','disabled');
    			button.removeClass('blue_btn');
    			button.addClass('gray_btn');
    		} else {
    			button.removeAttr('disabled');
    			button.removeClass('gray_btn');
    			button.addClass('blue_btn');
    		}
    	}
    	
    	function toggleViewEditMode(viewMode) {
    		var inputs = $('#paymentInfo input[type="text"]:not(.uneditable)');
    		var selects = $('#paymentInfo select:not(.uneditable)');
    		var textareas = $('#paymentInfo textarea:not(.uneditable)');
    		toggleInputOrSelectElement(viewMode,inputs);
    		toggleInputOrSelectElement(viewMode,selects);
    		toggleInputOrSelectElement(viewMode,textareas);
    
    		toggleButtons(viewMode,$('#add-paymentrequest-link'));
    		toggleButtons(viewMode,$('#cancelEditButton'));
    		toggleButtons(viewMode,$('#save'));
    		toggleButtons(viewMode,$('#saveAndAddNew'));
    		toggleButtons(!viewMode,$('#editButton'));
    		
    		var lineItemInputs = $('#paymentLineItems input');
    		var lineItemSelects = $('#paymentLineItems select');
    		for(var i = 0; i < lineItemInputs.length; i++) {
    			lineItemInputs[i].readonly = viewMode;
    			lineItemInputs[i].disabled = viewMode;
    		}
    		for(var i = 0; i < lineItemSelects.length; i++) {
    			lineItemSelects[i].readonly = viewMode;
    			lineItemSelects[i].disabled = viewMode;
    		}
    	}
</script>
<div id="editPaymentrequestDiv">
	<form:form name="editPaymentrequestForm" id="editPaymentrequestForm" action="processPaymentrequest.do?id=${paymentrequest.id}" method="post" modelAttribute="paymentrequest">
		<form:hidden path="id" />
		<div id="reason-dialog" style="display: none">
			<label><spring:message code="editPaymentrequest.label.reasonForRejection" />:&nbsp;</label><br/>
			<textarea id="dummyReasonRejected" style="width: 100%; height: 250px;"></textarea>
		</div>
		<div class="main_form">
			<div class="form_head">
				<div class="floatL" style="padding-top:5px; width: 800px;">
					<a href="#" id="btnSignatureAllUnpaid" class="blue_btn floatL" onclick="return false;" tabindex="-1">Signature Selection All Unpaid</a>
					<a href="#" id="btnOver30days" class="blue_btn floatL" onclick="return false;" tabindex="-1">Over 30 days past due</a>
					<a href="#" id="btnOutstandingWireTransfers" class="blue_btn floatL" onclick="return false;" tabindex="-1">Outstanding Wire Transfers</a>
					<a href="#" id="btnSignatureSelection" class="blue_btn floatL" onclick="return false;" tabindex="-1">Signature Selection Never Selected</a>
					<a href="#" id="instructions-link" class="blue_btn floatL" paymentrequestId="${paymentrequest.id}" tabindex="-1"><spring:message code="editPaymentrequest.label.instructions" /></a>
					<a href="#" id="printPaymentRequest" class="blue_btn floatL"  style="display: none;" onclick="return false;" tabindex="-1">&nbsp;</a>
					<a href="#" id="printWireForm" class="uneditable blue_btn floatL" tabindex="-1"><spring:message code="editPaymentrequest.label.printWireForm" /></a>
				</div>
				
				<a href="#" class="close-button gray_btn floatR" tabindex="-1">Close Form</a><br class="clear" />
	    	</div>
	    	<div class="form_cont">
				<table id="paymentInfo" cellspacing="10" width="100%">
					<tr>
						<td colspan="5" style="font-size: 16pt; text-align: center;">
							<spring:message code="editPaymentrequest.heading.availableAction" />
						</td>
					</tr>
					<tr>
						<td colspan="5" style="text-align: center;">
							<c:choose>
								<c:when test="${canCancelStatus}">
									<sj:submit id="cancelPaymentStatusButton" cssClass="uneditable" target="editPaymentrequestDiv" key="editPaymentrequest.label.cancel" tabindex="-1"/>
								</c:when>
								<c:otherwise>
									<sj:submit id="cancelPaymentStatusButton" cssClass="uneditable" target="editPaymentrequestDiv" key="editPaymentrequest.label.cancel" attr="disabled='disabled'" tabindex="-1"/>
								</c:otherwise>
							</c:choose>
							<c:choose>
								<c:when test="${canRejectStatus}">
									<sj:submit id="rejectPaymentStatusButton" target="editPaymentrequestDiv" cssClass="uneditable" key="editPaymentrequest.label.reject" validate="true" tabindex="-1" cssStyle="visibility: hidden; margin: 0; padding: 0; border: 0; float: left; width: 1px;"/>
									<input type="button" id="dummyRejectStatusButton" class="uneditable" value='<spring:message code="editPaymentrequest.label.reject" />' tabindex="-1"/>
								</c:when>
								<c:otherwise>
									<input type="button" id="dummyRejectStatusButton" class="uneditable"  disabled="disabled" value='<spring:message code="editPaymentrequest.label.reject" />' tabindex="-1"/>
									
								</c:otherwise>
							</c:choose>
							<c:if test="${!empty nextButtonValue}">
                            <c:choose>
                              <c:when test="${disableNextButtonValue}">
                                <sj:submit id="nextActionButton" cssClass="uneditable" target="content" value="${nextButtonValue}" nameKey="name.button.nextaction" validate="true" attr="disabled='disabled'"/>
                              </c:when>
                              <c:otherwise>
                                <sj:submit id="nextActionButton" cssClass="uneditable" target="content" value="${nextButtonValue}" nameKey="name.button.nextaction" validate="true" />
                              </c:otherwise>
                            </c:choose>
							</c:if>
						</td>
					</tr>
					<tr class="row">
						<td class="input-field" colspan="5" style="text-align: center;"><%@ include file="/common/messages.jsp"%></td>
					</tr>
                    <tr>
                      <td class="label"><spring:message code="editPaymentrequest.label.paymentIdentifiedInformation" /></td>
                      <td class="input-field">
                        <form:input path="id" cssClass="input-full-width text_grey uneditable" disabled="true" tabindex="-1"/>
                        <form:errors path="id" cssClass="error" />
                      </td>
                      <td width="50">&nbsp;</td>
                      <td class="label"><spring:message code="editPaymentrequest.label.dateToFinanace" /></td>
                      <td class="input-field">
                      <form:input path="dateToFinanace" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                      <form:errors path="dateToFinanace" cssClass="error" />
                      </td>
                    </tr>
                    <tr>
                      <td class="label"><spring:message code="label.originator" /></td>
                      <td class="input-field">
                      <input type="text" value="${paymentrequest.createdBy }" class="input-full-width text_grey uneditable" readonly="readonly" tabindex="-1" />
                      <form:errors path="createdBy" cssClass="error" />
                      </td>
                      <td width="50">&nbsp;</td>
                      <td class="label"><spring:message code="editPaymentrequest.label.dateforwardedforsignature" /></td>
                      <td class="input-field">
                      <form:input path="dateforwardedforsignature" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                      <form:errors path="dateforwardedforsignature" cssClass="error" />
                      </td>
                    </tr>
                    <tr>
                      <td class="label"><spring:message code="editPaymentrequest.label.datecreated" /></td>
                      <td class="input-field">
                      <form:input disabled="true" path="creationDate" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
                      </td>
                      <td width="50">&nbsp;</td>
                      <td class="label"><spring:message code="editPaymentrequest.label.datesubmittedforpayment" /></td>
                      <td class="input-field">
                      <form:input path="datesubmittedforpayment" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                      <form:errors path="datesubmittedforpayment" cssClass="error" />
                      </td>
                    </tr>
                    <tr>
                      <td class="label"><spring:message code="editPaymentrequest.label.responsibleNextAct" /></td>
                      <td class="input-field">
                      <form:input path="currentlyresponsible" cssClass="input-full-width text_grey uneditable" disabled="true" tabindex="-1"/>
                      <form:errors path="currentlyresponsible" cssClass="error" />
                      </td>
                      <td width="50">&nbsp;</td>
                      <td class="label"><spring:message code="editPaymentrequest.label.datepaid" /></td>
                      <td class="input-field">
                      <form:input path="datePaid" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                      <form:errors path="datePaid" cssClass="error" />
                      </td>
                    </tr>
                    <tr>
                      <td class="label" style="color: red"><spring:message code="editPaymentrequest.label.currentStatus" /></td>
                      <td class="input-field">
                      <span style="color:red"><form:input path="statusCode" cssClass="input-full-width text_grey uneditable" disabled="true" tabindex="-1"/></span>
                      <form:errors path="statusCode" cssClass="error" />
                      </td>
                      <td width="50">&nbsp;</td>
                      <td class="label"><spring:message code="editPaymentrequest.label.daterejected" /></td>
                      <td class="input-field">
                      <form:input path="dateRejected" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                      <form:errors path="dateRejected" cssClass="error" />
                      </td>
                    </tr>
                    <tr>
                      <td class="label"><spring:message code="editPaymentrequest.label.payee" /></td>
                      <td class="input-field" nowrap="nowrap">
                      <form:select path="payeeId" cssClass="input-full-width-req text_grey" disabled="true" tabindex="1">
                        <form:option value="" label="Select" />
                        <form:options items="${payeeList}" itemValue="id" itemLabel="payeeName" />
                      </form:select>
                      <form:hidden path="payeeDesc"/>
                      <input id="add-paymentrequest-link" type="button" class="blue_btn" value="<spring:message code="label.edit" />" payeeId="${paymentrequest.payeeId}" />&nbsp;
                      </td>
                      <td width="50">&nbsp;</td>
                      <td class="label"><spring:message code="editPaymentrequest.label.rejectedreason" /></td>
                      <td class="input-field">
                      <c:choose>
                        <c:when test="${paymentrequest.statusCode == 'Rejected'}">
                        <form:textarea path="reasonrejected" cssClass="input-full-width text_white" tabindex="10"/>
                        <form:errors path="reasonrejected" cssClass="error" />
                        </c:when>
                        <c:otherwise>
                        <form:textarea path="reasonrejected" cssClass="input-full-width text_grey uneditable" disabled="true" tabindex="10"/>
                        </c:otherwise>
                      </c:choose>
                      </td>
                    </tr>
                    <tr>
                      <td class="label"><spring:message code="editPaymentrequest.label.payeeAddress" /></td>
                      <td class="input-field">
                      <input id="payeeAddress" class="text_grey uneditable" readonly="readonly" tabindex="-1" />
                      </td>
                      <td width="50">&nbsp;</td>
                      <td class="label"><spring:message code="editPaymentrequest.label.dateresubmitted" /></td>
                      <td class="input-field">
                      <form:input path="dateResubmitted" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                      <form:errors path="dateResubmitted" cssClass="error" />
                      </td>
                    </tr>
                    <tr>
                      <td class="label"><spring:message code="editPaymentrequest.label.invoiceno" /></td>
                      <td class="input-field">
                      <form:input path="invoicenumber" cssClass="input-full-width  text_grey" disabled="true" tabindex="2"/>
                      <form:errors path="invoicenumber" cssClass="error" />
                      </td>
                      <td width="50">&nbsp;</td>
                      <td class="label"><spring:message code="editPaymentrequest.label.datecancelrequested"/></td>
                      <td class="input-field">
                      <form:input path="dateCancelRequested" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                      <form:errors path="dateCancelRequested" cssClass="error" />
                      </td>
                    </tr>
                    <tr>
                      <td class="label"><spring:message code="editPaymentrequest.label.invoiceRequestDate" /></td>
                      <td class="input-field">
                      <form:input path="invoiceRequestDate" cssClass="input-full-width text_grey" disabled="true" tabindex="3"/>
                      <form:errors path="invoiceRequestDate" cssClass="error" />
                      </td>
                      <td width="50">&nbsp;</td>
                      <td class="label"><spring:message code="editPaymentrequest.label.datecancelled" /></td>
                      <td class="input-field">
                      <form:input path="dateCancelled" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                      <form:errors path="dateCancelled" cssClass="error" />
                      </td>
                    </tr>
                    <tr>
                      <td class="label"><spring:message code="editPaymentrequest.label.paymentrequesttype" /></td>
                      <td class="input-field">
                      <form:select path="paymentTypeId" cssClass="input-full-width-req text_grey" disabled="true" tabindex="4">
                        <form:option value="" label="Select" />
                        <form:options items="${paymenttypeList}" itemValue="id" itemLabel="paymenttypename" />
                      </form:select>
                      <form:errors path="paymentTypeId" cssClass="error" />
                      </td>
                      <td width="50">&nbsp;</td>
                      <td class="label"><spring:message code="editPaymentrequest.label.checkConfirmNumber" /></td>
                      <td class="input-field">
                      <form:input path="paymentConfirmationNumber" cssClass="input-full-width text_grey" disabled="true" tabindex="8"/>
                      <form:errors path="paymentConfirmationNumber" cssClass="error" />
                      </td>
                    </tr>
                    <tr>
                      <td class="label"><spring:message code="editPaymentrequest.label.paymentmethod" /></td>
                      <td class="input-field"><form:select path="paymentMethod" cssClass="input-full-width-req text_grey" disabled="true" tabindex="5">
                        <form:option value="" label="Select" />
                        <form:option value="Wire" label="Wire" />
                        <form:option value="Check" label="Check" />
                        <%-- Commented due to ERR-24 
                        <form:option value="Other" label="Other" />
                        --%>
                      </form:select>
                      <form:errors path="paymentMethod" cssClass="error" />
                      </td>
                      <td width="50">&nbsp;</td>
                      <td class="label"><spring:message code="editPaymentrequest.label.comments" /></td>
                      <td class="input-field">
                      <form:input path="comments" cssClass="input-full-width text_grey" disabled="true" tabindex="9"/>
                      <form:errors path="comments" cssClass="error" />
                      </td>
                    </tr>
                    <tr>
                      <td class="label"><spring:message code="editPaymentrequest.label.purposeOfExpenditure" /></td>
                      <td class="input-field">
                      <form:input path="purposeOfExpenditure" cssClass="input-full-width-req text_grey" dir="true" tabindex="6"/>
                      <form:errors path="purposeOfExpenditure" cssClass="error" />
                      </td>
                      <td width="50">&nbsp;</td>
                      <td class="label"><spring:message code="label.updatedBy" /></td>
                      <td class="input-field">
                      <input type="text" value="${paymentrequest.updatedBy }" class="input-full-width text_grey uneditable" readonly="readonly" tabindex="-1"/>
                      <form:errors path="updatedBy" cssClass="error" />
                      </td>
                    </tr>
                    <tr>
                      <td class="label"><spring:message code="editPaymentrequest.label.specialInstructions" /></td>
                      <td class="input-field">
                      <form:input path="specialInstructions" cssClass="input-full-width text_grey" disabled="true" tabindex="7"/>
                      <form:errors path="specialInstructions" cssClass="error" />
                      </td>
                      <td width="50">&nbsp;</td>
                      <td class="label"><spring:message code="label.updationDate" /></td>
                      <td class="input-field">
                      <form:input disabled="true" path="updationDate" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
                      <form:errors path="updationDate" cssClass="error" />
                      </td>
                    </tr>
                    <tr>
                      <td class="label"><spring:message code="editPaymentrequest.label.amount" /></td>
                      <td class="input-field">
                      <form:hidden path="amount" cssClass="input-full-width text_grey uneditable" />
                      <input type="text" value="&nbsp;" readonly="readonly"  id="amountLabel" class="text_grey uneditable" tabindex="-1" style="font-size: 2em;"/>
                      <form:errors path="amount" cssClass="error" />
                      </td>
                      <td width="50">&nbsp;</td>
                    </tr>
				</table>
				<div id="paymentLineItems">
				</div>
				<div style="text-align: center;">
					<br />
                    <c:choose>
                      <c:when test="${empty canEdit || !canEdit}">
                        <input id="editButton" type="button" class="gray_btn" value="Edit" disabled="disabled" tabindex="-1">
                        <input id="cancelEditButton" type="button" class="gray_btn" value="Cancel Edit" disabled="disabled" tabindex="-1">
                        <sj:submit id="save" cssClass="gray_btn" target="editPaymentrequestDiv" key="editPaymentrequest.button.save" attr="disabled='disabled'" validate="true" tabindex="-1"/>
                      </c:when>
                      <c:otherwise>
                        <input id="editButton" type="button" class="blue_btn" value="Edit" tabindex="-1">
                        <input id="cancelEditButton" type="button" class="gray_btn" value="Cancel Edit" disabled="disabled" tabindex="-1">
                        <sj:submit id="save" cssClass="gray_btn" target="editPaymentrequestDiv" key="editPaymentrequest.button.save" attr="disabled='disabled'" validate="true" tabindex="-1"/>                    
                      </c:otherwise>
                    </c:choose>
					
					<br />
					<br />			
				</div>
			</div>
		</div>
	</form:form>
	<script type="text/javascript">
		$(document).ready(function() {
			$('table.tablesorter').tablesorter({
				widgets : [ 'zebra' ],
				sortList : [ [ 0, 0 ], [ 1, 0 ] ],
				headers : {
					10 : {
						sorter : false
					}
				}
			});

			$('.edit-paymentrequestaward-link').click(function() {
				loadDiv('content', 'showEditPaymentrequest.do?id=' + $(this).attr('paymentrequestawardId'));
			});
		});
	</script>
</div>
